#pragma once

#include <Ogre.h>
#include <OIS/OIS.h>
using namespace Ogre;

#define NINJA_NUM_ANIMS 20
#define NINJAFRAMESCALE	0.0010f
class Ninja
{

private:
	enum AnimID
	{
		ATTACK1,	ATTACK2,
		ATTACK3,	BACKFLIP,
		BLOCK,		CLIMB,
		CROUCH,		DEATH1,
		DEATH2,		HIGHJUMP,
		IDLE1,		IDLE2,
		IDLE3,		JUMP,
		JUMPNOHEIGHT,	KICK,
		SIDEKICK,		SPIN,
		STEALTH,	WALK, ANIM_NONE
	};
	
	
	AnimationState*				m_pAnims[NINJA_NUM_ANIMS];
	Real						m_rTimers;
	SceneManager*				m_pSceneMgr;
	Entity*						m_pNinjaRootEntity;
	SceneNode*					m_pNinjaRootNode;
	
	Entity*						m_pNinjaEntity;
	SceneNode*					m_pNinjaNode;
	Entity*						m_pNinjaRangeAEntity;
	SceneNode*					m_pNinjaRangeANode;
	Entity*						m_pNinjaRangeBEntity;
	SceneNode*					m_pNinjaRangeBNode;
	Entity*						m_pNinjaRangeCEntity;
	SceneNode*					m_pNinjaRangeCNode;
	Entity*						m_pNinjaCollisionEntity;
	SceneNode*					m_pNinjaCollisionNode;

	SceneNode*					m_pNinjaParticleNode;
	Ogre::String				m_sParticleName;

	float						m_fHP;
	bool						m_bDead;
	SceneNode*					m_pSciritNode;

	AnimID						m_aAnimID;
	bool						m_nEnterRangeA;
	bool						m_nEnterRangeB;
	bool						m_nEnterRangeC;

	Vector3						m_vNinjaPos;
	// sinbad object
	SceneNode*					m_pCheckNode;

	static int					m_nCount;
protected:
	
	void	setupAnimations();
	void	setAnimationState(AnimID id, bool result);
	void	updateAnimations(const Ogre::FrameEvent &evt);
	void	checkCollisionObject();
	void	randomAnimation();
public:
	Ninja(SceneManager* mscenemgr);
	~Ninja(void);

	void createNinja(SceneNode*	mCheckObject, Vector3 Pos = Vector3::ZERO);
	
	void updateNinja(const Ogre::FrameEvent &evt);
	
	void calcDead(float attack);
	
	void destroyNinja();
	void setPos(Vector3& mPos)
	{
		m_vNinjaPos = mPos;
		m_pNinjaRootNode->setPosition(mPos);
	}
	
	SceneNode*  getCollisionObject()
	{
		
		return m_pNinjaCollisionNode;
		
	}

	SceneNode*  getRootObject()
	{

		return m_pNinjaRootNode;

	}


	bool isDead()
	{
		return m_bDead;
	}
	
	Vector3 getRootPos()
	{
		return m_vNinjaPos;
	}
};
